package com.heima.controller;


import com.baomidou.mybatisplus.extension.api.R;
import com.heima.common.constants.UserConstants;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.dtos.AuthDto;
import com.heima.service.ApUserRealnameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/ApUserRealname")
public class ApUserRealnameController {

    @Autowired
    private ApUserRealnameService apUserRealnameService ;


    /**
     * 根据状态查询用户认证列表
     *
     * @param authDto
     * @return
     */
    @GetMapping("/ApUserList")
    public ResponseResult ApUserList(@RequestBody AuthDto authDto){
        ResponseResult apUserList = apUserRealnameService.ApUserList(authDto);

        return ResponseResult.okResult(apUserList);
    }

    /**
     *
     * 审核通过
     * @param authDto
     * @return
     */
    @PostMapping("/authpass")
    public ResponseResult authPass(@RequestBody AuthDto authDto){
        return apUserRealnameService.updateStatusById(authDto, UserConstants.PASS_AUTH);
    }

    /**
     * 审核失败
     * @param authDto
     * @return
     */
    @PostMapping("/authFail")
    public ResponseResult  authFail(@RequestBody AuthDto authDto){
        return apUserRealnameService.updateStatusById(authDto,UserConstants.FAIL_AUTH);
    }
}
